//
//  SearchCell.m
//  MountEverestFM
//
//  Created by dllo on 15/11/8.
//  Copyright © 2015年 chenn. All rights reserved.
//

#import "HistorySearchTableViewCell.h"
#import "SearchHistoryCollectionViewCell.h"
@implementation HistorySearchTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.flowLayout=[[UICollectionViewFlowLayout alloc]init];
        self.flowLayout.itemSize=CGSizeMake(FM_Screen_Pts_Width*100, FM_Screen_Pts_Height*40);
        
        self.flowLayout.sectionInset=UIEdgeInsetsMake(0, 10, 0, 10);
        
        self.collection=[[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:self.flowLayout];
        self.collection.delegate=self;
        self.collection.dataSource=self;
        [self.contentView addSubview:self.collection];
        
        [self.collection registerClass:[SearchHistoryCollectionViewCell class] forCellWithReuseIdentifier:@"feijin1"];
        
        self.lable=[[UILabel alloc]init];
        [self.contentView addSubview:self.lable];
        
        self.button=[UIButton buttonWithType:UIButtonTypeSystem];
        [self.contentView addSubview:self.button];
        
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.collection.frame=CGRectMake(0, 0, FM_Screen_Width, self.contentView.frame.size.height);
    self.collection.backgroundColor=[UIColor whiteColor];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.arr.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    SearchHistoryCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"feijin1" forIndexPath:indexPath];
    self.strr=[[self.arr objectAtIndex:indexPath.item] titelStr ];
    cell.lable.text=self.strr;
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    self.block(self.strr);
}

- (void)setArr:(NSArray *)arr
{
    if (_arr != arr) {
        _arr = arr;
    }
    [self.collection reloadData];
}

@end
